package com.english.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 班级课时变动日志表
 *
 * @author wlq
 * @since 2025-08-06
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("class_hours_log")
public class ClassHoursLog implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 学生ID
     */
    @TableField("student_id")
    private Long studentId;

    /**
     * 班级ID
     */
    @TableField("class_id")
    private Long classId;

    /**
     * 变动数量：正数=增加，负数=减少
     */
    @TableField("change_value")
    private Integer changeValue;

    /**
     * 变动类型
     */
    @TableField("change_type")
    private ChangeType changeType;

    /**
     * 变动标题
     */
    @TableField("title")
    private String title;

    /**
     * 变动描述/原因
     */
    @TableField("description")
    private String description;

    /**
     * 变动前课时数
     */
    @TableField("before_hours")
    private Integer beforeHours;

    /**
     * 变动后课时数
     */
    @TableField("after_hours")
    private Integer afterHours;

    /**
     * 操作管理员ID
     */
    @TableField("admin_id")
    private Long adminId;

    /**
     * 关联充值记录ID
     */
    @TableField("recharge_id")
    private Long rechargeId;

    /**
     * 关联签到记录ID
     */
    @TableField("attendance_id")
    private Long attendanceId;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    // 关联信息（非数据库字段）
    @TableField(exist = false)
    private String studentName;

    @TableField(exist = false)
    private String className;

    @TableField(exist = false)
    private String adminName;

    /**
     * 变动类型枚举
     */
    public enum ChangeType {
        RECHARGE("充值"),
        CLASS_CONSUMPTION("课程消耗"),
        MANUAL_ADJUSTMENT("手动调整"),
        SIGN_OUT("签退扣减");

        private final String description;

        ChangeType(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
} 